﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.ServiceProcess;

namespace ZgOffice.SvrMangr
{
    public partial class StatusUserControl : DevExpress.XtraEditors.XtraUserControl
    {
        public StatusUserControl()
        {
            InitializeComponent();
            tServerName.Text = "ZGOfficeService";
        }

        private void startBtn_Click(object sender, EventArgs e)
        {
            try
            {
                ServiceController serviceController = new ServiceController(tServerName.Text);
                serviceController.Start();
            }
            catch(Exception ex)
            {
                MessageBox.Show("启动失败，可能服务尚未安装！" + ex.Message);
            }
            
        }

        private void stopBtn_Click(object sender, EventArgs e)
        {
            try
            {
                ServiceController serviceController = new ServiceController(tServerName.Text);
                if (serviceController.CanStop)
                    serviceController.Stop();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            
        }
    }
}
